#!/bin/awk -f
## expect 1 argument : chemistry v ariant name 
## chemistry file is stdinp
BEGIN{
  deflab=ARGV[1]; ARGV[1]="-";
  err=-1;
}
$1=="defch"{nch++;ch[nch]=$2;next;}
$0!~/^ *\#/{
  if($1==deflab){
    n=split($2,a,",");
    if(n==nch){
      chs=n" ";
      for(i=1;i<=nch;i++){
	chs=chs" "ch[i]" "a[i]" ";
      }
      err=0;
    }else{
      err=-2;
    }
  }
}
END{
  print err,chs;
}
